#ifndef INTERSECTION_H
#define INTERSECTION_H

// ----------------------------------------------------------------------------
// ray triangle 

// WARNING: test against front faced triangles only 
// from Fast, Minimum Storage Ray/Triangle Intersection Moller&Trumbore
bool rayTriTest (const rgVector& tri0, const rgVector& tri1, const rgVector& tri2, 
                 const rgVector& rayO, const rgVector& rayD, 
                 rgReal& t, rgReal& u, rgReal& v, rgReal& det);

// feed in rayTriIntersection return values
rgVector getRayTriPoint (const rgVector& rayO, const rgVector& rayD, const rgReal& t, const rgReal& det);

// feed in rayTriIntersection return values
void getRayTriUV (rgReal& u, rgReal& v, const rgReal& det);

// use getRayTriPoint like this (hint: same for getRayTriUV)
bool rayTriTestPoint(const rgVector& tri0, const rgVector& tri1, const rgVector& tri2, 
                     const rgVector& rayO, const rgVector& rayD,
                     rgVector& p);


// ----------------------------------------------------------------------------
// ray sphere

// from Real-Time Rendering 2nd ed
bool raySphereTest (const rgVector& c, const rgReal& r,
                    const rgVector& rayO, const rgVector& rayD,
                    rgReal& t);

rgVector getRaySpherePoint (const rgVector& rayO, const rgVector& rayD,
                         const rgReal& t);

bool raySphereTestPoint (const rgVector& c, const rgReal& r,
                         const rgVector& rayO, const rgVector& rayD,
                         rgVector& p);
#endif

